var lastValue = "", nodeList = [], fontCss = {};
var tloadinit;
ztreeLayerOpenSelectedUtils = {
	openSelectedShowDefault : function(checkIdsText,checkNamesText,showText,openUrl){
		//打开树后，选择节点返回给父页面
		var ids = $("#"+checkIdsText).val();
		var checkName = $("#"+checkNamesText).val();
		ids = functionUtil.replaceAllValue(ids,"#","_");
		checkName = functionUtil.replaceAllValue(checkName,"#","_");
		var titles = "选择权限";
		top.layer.open({
		  type: 2,
		  title: titles,
		  shade: 0.5,//背景色深度
		  fixed: false, //不固定
		  maxmin: true,
		  anim : 1,
		  shadeClose: false,//点击其它区域关闭
		  content:  openUrl,
		  area: ['300px' , '380px'],
		  btn : ["提交",'关闭'],
		  yes : function(index,layero){
			  var body = top.layer.getChildFrame('body',index);
				var iframeWin = layero.find('iframe')[0];//得到iframe页的窗口对像，执行iframe页的方法，iframeWin.method();
				var values = iframeWin.contentWindow.ztreeLayerOpenSelectedUtils.returnArrayIsCheckResult(checkIdsText,checkNamesText);
				if(values!=''){
					//表单提交后，先延时1秒去取异步结果，如果还不成功，再延时3秒去取结果，正常的逻辑时间够了，如果是有大内容就得再回5秒或10秒
					$("#"+checkIdsText).val(values.ids);
					$("#"+checkNamesText).val(values.checkName);
					$("#"+showText).html(values.showname);
					top.layer.close(index);
				}
		  },
		  end: function(index){
			  
		  }
		});  
	},
	openSelectedShowByWH : function(checkIdsText,checkNamesText,showText,openUrl,w,h){
		//打开树后，选择节点返回给父页面
		var ids = $("#"+checkIdsText).val();
		var checkName = $("#"+checkNamesText).val();
		ids = functionUtil.replaceAllValue(ids,"#","_");
		checkName = functionUtil.replaceAllValue(checkName,"#","_");
		var titles = "选择权限";
		top.layer.open({
		  type: 2,
		  title: titles,
		  shade: 0.5,//背景色深度
		  fixed: false, //不固定
		  maxmin: true,
		  anim : 1,
		  shadeClose: false,//点击其它区域关闭
		  content:  openUrl+'?ids='+ids+'&checkName='+checkName,
		  area: [w+'px' , h+'px'],
		  btn : ["提交",'关闭'],
		  yes : function(index,layero){
			  var body = top.layer.getChildFrame('body',index);
				var iframeWin = layero.find('iframe')[0];//得到iframe页的窗口对像，执行iframe页的方法，iframeWin.method();
				var values = iframeWin.contentWindow.ztreeLayerOpenSelectedUtils.returnArrayIsCheckResult(checkIdsText,checkNamesText);
				if(values!=''){
					//表单提交后，先延时1秒去取异步结果，如果还不成功，再延时3秒去取结果，正常的逻辑时间够了，如果是有大内容就得再回5秒或10秒
					$("#"+checkIdsText).val(values.ids);
					$("#"+checkNamesText).val(values.checkName);
					$("#"+showText).html(values.showname);
					top.layer.close(index);
				}
		  },
		  end: function(index){
			  
		  }
		});  
	},
	browseOpenByWH : function(openUrl,titles,w,h){
		//var titles = title;//"浏览角色【"+rolename+"】权限";
		top.layer.open({
		  type: 2,
		  title: titles,
		  shade: 0.5,//背景色深度
		  fixed: false, //不固定
		  maxmin: true,
		  anim : 1,
		  shadeClose: false,//点击其它区域关闭
		  content:  openUrl,//'ztreeAsyncPostLayer.do?rid='+rid,
		  area: [w+'px' , h+'px'],
		  btn : ['关闭'],
		  end: function(index){
			  
		  }
		});  
	},
	returnArrayIsCheckResult : function(checkIdsText,checkNamesText){
		var array={};
		var ids = $("#"+checkIdsText).val();
		var v = $("#"+checkNamesText).val();
		if(ids!=''){
			var html ='';
			var arrids = ids.split('#',-1);
			var arrname = v.split('#',-1);
			$.each(arrids, function(i, id) {
				if(i%2==0){
					html +='<button type="button" id="authority_'+id+'" class="btn btn-xs btn-info" style="margin-bottom:5px;margin-right:15px;">【'+arrname[i]+'】&nbsp;</button><span class="btn-danger circle_del" id="authority_span_'+id+'" title="移除" onclick="removeAu('+id+',\''+arrname[i]+'\')">x</span>';
				}else{
					html +='<button type="button" id="authority_'+id+'" class="btn btn-xs btn-success" style="margin-bottom:5px;margin-right:15px;">【'+arrname[i]+'】&nbsp;</button><span class="btn-danger circle_del" id="authority_span_'+id+'" title="移除" onclick="removeAu('+id+',\''+arrname[i]+'\')">x</span>';
				}
			});
			array.ids=ids;
			array.showname = html;
			array.checkName = v;
			return array;
		}
		return "";
	}
}
